package com.eric.enderslastgame.threads;

import java.util.ArrayList;

import android.view.SurfaceHolder;

import com.eric.enderslastgame.Bugger;
import com.eric.enderslastgame.EndersGamePanel;

public class BugGenThread extends Thread {

	private static final String TAG = BugGenThread.class.getSimpleName();

	// Surface holder that can access the physical surface
	private SurfaceHolder surfaceHolder;
	// The actual view that handles inputs
	// and draws to the surface
	private EndersGamePanel gamePanel;
	
	public BugGenThread(SurfaceHolder surfaceHolder, EndersGamePanel gamePanel) {
		super();
		this.surfaceHolder = surfaceHolder;
		this.gamePanel = gamePanel;
	}

	@Override
	public void run() {
		while (EndersGamePanel.inGame) {
			// System.out.println("Current set gen: " + currentSetGen);
			ArrayList<Bugger> buggerList = gamePanel.buggers.get(gamePanel.currentSetGen);
			gamePanel.generateBugger(buggerList);

			try {
				sleep(gamePanel.bugGenSleepTime);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
